﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>登录</title>
    <meta charset='UTF-8'>
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no,email=no" name="format-detection" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />
    <link href="../Content/alipay/alipay.css" type="text/css" rel="stylesheet" />
    <link href="../Content/alipay/amui-demo_files/toast.css" type="text/css" rel="stylesheet" />
    <link href="../Content/alipay/button.css" type="text/css" rel="stylesheet" />
    <link href="../Content/alipay/amui-demo_files/dialog.css" type="text/css" rel="stylesheet" />
    <link href="../Content/alipay/amui-demo_files/button-group.css" type="text/css" rel="stylesheet" />

    <script type="text/javascript" src="../Scripts/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="../Scripts/extensions/base.js"></script>
    <script type="text/javascript" src="../Content/alipay/amui-demo_files/amui.js"></script>
</head>
<body>
    <div data-role="page">
        <div data-role="content" style="background-color:#EFEFF4;padding-top:15px;">
                <div class="am-list-body">
                    <div class="am-list" am-mode="flat form">
                        <div class="am-list-item am-input-autoclear">
                            <div class="am-list-control">
                                <input type="text" placeholder="手机号/会员名" id="loginId" value="">
                            </div>
                            <div class="am-list-clear"><i class="am-icon-clear am-icon" am-mode="clear" style="visibility: hidden;"></i></div>
                        </div>
                        <div class="am-list-item am-input-autoclear">
                            <div class="am-list-control">
                                <input type="password" placeholder="登录密码" id="password" value="">
                            </div>
                            <div class="am-list-clear"><i class="am-icon-clear am-icon" am-mode="clear" style="visibility: hidden;"></i></div>
                        </div>
                    </div>
                </div>
                <div class="am-list-footer am-ft-right" style="font-size:14px;padding-top:15px;">
                    <a onclick="turn()">注册新账号</a>
                </div>
                </div>
           
                <div style="padding-left:15px;padding-right:15px;margin-top:3PX;">
                    <button id="searchButton" type="button" class="am-button" am-mode="blue disabled"onclick="login()">绑定</button>
                </div>
            </div>
    <div id="fuwu" style="display: block;font-family:STHeitiSC;font-size: 12px; margin-bottom: 15px; margin-left: 0px; width: 100%; text-align: center;   position: absolute; bottom: 0px;z-index:-1;">
        <div class="am-agreement am-ft-gray am-ft-sm">
            <p>
                本服务由大庆公安厅<br />江苏欧索软件有限公司提供技术支持
            </p>
        </div>
    </div>

            <script type="text/javascript">
                $(function () {
                    window.setInterval("checkButtonState()", 200);
                    
                });
                function checkButtonState() {
                    if ($("#loginId").val() && $("#password").val())
                        $("#searchButton").attr("am-mode", "blue");
                    else
                        $("#searchButton").attr("am-mode", "blue disabled");
                }
                function getCookie(key) {
                    var keyValues = document.cookie.split(";");
                    for (var index = 0; index < keyValues.length; index++) {
                        var keyValue = keyValues[index].split("=");
                        if (keyValue[0].trim() == key)
                            return keyValue[1];
                    }
                    return null;
                }
                function login()
                {
                    var type = decodeURI(getQueryStringByName("type"));
                    var openId = getCookie("openID");
                    var loginId = $("#loginId").val();
                    var password = $("#password").val();
                    var url = "../../CityService.Service/PoliceService.svc/Login";
                    
                    $.ajax(url, {
                        type: 'Get',
                        data: {
                            loginId:loginId,
                            password: password,
                            openId:openId
                        },
                        success: function (msg)
                        {
                            var result = JSON.parse(msg.d);
                            if (result.succ ==true)
                            {
                                var guid = result.data.guid;
                                document.cookie = "guid=" + guid;
                                if (type == 1) {
                                    location.href = "AskQuestion.html";
                                }
                                else if (type ==2) {
                                    location.href = "MyConsulting.html";
                                }
                            }
                            else
                            {
                                alert(result.msg);
                            }
                        },
                        error: function (){ },
                        complete: function ()
                        {

                        }
                    });
                }
                function turn()
                {
                    var type = getQueryStringByName("type");
                    location.href = "Register.html?type="+type;
                }
            </script>

</body>
</html>